@FindBy(id = "htmlIdOfTheElement") private WebElement yourElement;
It is a way to wire-up you tests with the elements from the tested page. Graphene indeed supports a @FindBy mechanism, well-known from WebDriver project. That means support for e.g. css, id, tagName and other default location strategies. Graphene adds some goodies to this mechanism, check out FindBy annotation page for more info.
@FindBy(id = "htmlIdOfTheElement") private WebElement yourElement;
However, it lacks support for custom location strategies. Graphene comes with ability to extend it, and at the same time provides an actual extension: @FindByJQuery annotation, which brings JQuery selectors to your tests.
To introduce own strategy, lets say for angular.js, one needs to simply:
Be inspired with ByJQuery class.
An implementation can look like following snippet:
public static class AngularLocationStrategy implements LocationStrategy { @Override public ByAngular fromAnnotation(Annotation annotation) { FindByAngular findBy = (FindByAngular) annotation; return new ByAngular(findBy.value()); } }
@Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) @ImplementsLocationStrategy(ByAngular.AngularLocationStrategy.class) public @interface FindByAngular { String value(); }
@FindByAngular("modelProperty") private WebElement foo;